#e
#Title[u\i@̔p~v]
#Text[XgXyFlނ͏\i@p~܂EEEB]

#BackGround[Default]
#BGM[.\BGM\x_fear]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
	let count=-300;
	let imgExRumia=GetCurrentScriptDirectory~"img\ExRumia.png";	
        let eco00=GetCurrentScriptDirectory~"SE\eco00.wav";
	let imgLittle=GetCurrentScriptDirectory~"img\RumiaCutIn.png";
        let flame=-900;
        let shot1=GetCurrentScriptDirectory~"SE\shot1.wav";
        let bom36=GetCurrentScriptDirectory~"SE\bom36.wav";
        let x_fear=GetCurrentScriptDirectory~"BGM\x_fear.mp3";
        let kurokiyo=GetCurrentScriptDirectory~"BGM\kurokiyo.mp3";
	let imgback04_06=GetCurrentScriptDirectory~"img\back04_06.png";
	let imgLuna=GetCurrentScriptDirectory~"img\ExRumiaBack.png";
	let imgeffect_magic=GetCurrentScriptDirectory~"img\effect_magic.png";
	let imgAngle=0;

        @Initialize
	{

		SetLife(1200);//Ct500ɐݒ
		SetDamageRate(10,2);//_[W10%ɐݒ
		SetTimer(150);//Ԑ60bɐݒ
                SetDurableSpellCard();//ϋvXyJɂ܂
		SetGraphicRect(1,1,64,64);//`挳`ݒ		
		LoadGraphic(imgExRumia);//摜uimg\ExRumia.pngvǂ݂
		LoadGraphic(imgLuna);
		LoadGraphic(imgeffect_magic); 		
                LoadSE(eco00);
                FadeOutMusic(x_fear,8);
                LoadMusic(kurokiyo);
                SetMovePosition03(GetCenterX,GetCenterY-115,30,5);

	}
	
	@MainLoop
	{
          if(flame== -200)
                 {
                  PlayMusic(kurokiyo);
		  CutIn(YOUMU,"u\i@̔p~v",imgLittle,1,1,350,525);//XyJ[h\
		  SetScore(30000);//XyJ[h{[iX30000ɐݒ
                 }


       
         if(count==600){count = 0;}

         if(flame>0)
           {  

             if(count==240)
		{
                        let j=0;
                        let h=3;
                        while(h>0)
                            {
                               loop(18) {                               
				         CreateShot02(GetX,GetY,h,GetAngleToPlayer+j,0.03,8,RED03,50);//e𔭎
                                           
                                         j+=20;
                                        }
                               h-=0.3;
                             }
                }
	    }

         if(flame>0)
           {  

             if(count==360)
		{
                        let j=0;
                        let h=rand(0,360);
                               loop(85) {                               
				         CreateShot02(GetX,GetY,5,j+h,-0.05,3,AQUA02,0);//e𔭎
                                          
                                         j+=17;
                                        }
                             
                }
	    }

         if(flame>0)
           {  

             if(count==340)
		{
                        let j=0;
                        let h=rand(0,360);

                               loop(85) {                               
				         CreateShot02(GetX,GetY,5,j+h,-0.07,1,WHITE04,0);//e𔭎
                                         
                                         j+=17;
                                        }
                             
                }
	    }
       
        if(flame >0) 
         {
           if(count==400)
              {
                 let j=rand(0,360);
                 let dimasama=0;
                 let misyakujisama=0;
                 let i=0;
            
                  loop(36)
                   {
                    CreateShotA(dimasama,GetX,GetY,20);
                    SetShotDataA(dimasama,0,8,i+j,1.2,-0.3,1,PURPLE12);
                    SetShotDataA(dimasama,100,NULL,NULL,0.15,0,1,PURPLE12);
                    FireShot(dimasama);


                    CreateShotA(misyakujisama,GetX,GetY,20);
                    SetShotDataA(misyakujisama,0,8,i+j,-1.2,-0.3,1,PURPLE12);
                    SetShotDataA(misyakujisama,100,NULL,NULL,-0.15,0,1,PURPLE12);
                    FireShot(misyakujisama);
                    i+=10;
                   }
               }
           if(count==450)
              {
                 let j=rand(0,360);
                 let dimasama=0;
                 let misyakujisama=0;
                 let i=0;
            
                  loop(36)
                   {
                    CreateShotA(dimasama,GetX,GetY,20);
                    SetShotDataA(dimasama,0,8,i+j,1.2,-0.3,1,PURPLE12);
                    SetShotDataA(dimasama,100,NULL,NULL,0.15,0,1,PURPLE12);
                    FireShot(dimasama);


                    CreateShotA(misyakujisama,GetX,GetY,20);
                    SetShotDataA(misyakujisama,0,8,i+j,-1.2,-0.3,1,PURPLE12);
                    SetShotDataA(misyakujisama,100,NULL,NULL,-0.15,0,1,PURPLE12);
                    FireShot(misyakujisama);
                    i+=10;
                   }
               }
         }

         if(flame>1200)
           {  

             if(count<36&&count%3==0)
		{
                               let radius=80;
                               let angle=0;
                               loop(10) {
                                        let g = GetX + offsetX(radius, angle);
                                        let t = GetY + offsetY(radius, angle);                                
				         CreateShot02(g,t,4,angle+count*0.8,-0.2,1.5,BLUE23,50);//e𔭎
                                         angle+=36;                                      
                                        }

                }
	    }

         if(flame>660)
           {  

             if(count>540&&count%4==0)
		{
                               let h=60;
                               loop(10) {                               
				         CreateShot02(GetX,GetY,6,h-count*0.25,-0.2,1.5,RED21,0);//e𔭎
                                         h+=36;                                       
                                        }

                }
	    }
         if(flame>1200)
           {
                if(count>440&&count%20==2)		
                {
                        let j=3;
                        while(j>1)
                        {
                            let angle = 30;
                            loop(15) {
                                     CreateShot01(GetX, GetY, j, angle, GREEN22, 0);
                                     angle += 24;
                                     }
                            j-=1
                        }
                 }
            }

         if(flame>1800)
              {
                if(count>440&&count%20==2)		
                {
                        let j=3;
                        while(j>1)
                        {
                            let angle = 90;
                            loop(4) {
                                     CreateLaser01(GetX, GetY,j+1, angle,90, 15, GREEN01, 0);
                                     CreateLaser01(GetX, GetY,j, 45-angle,50, 5, GREEN01, 0);
                                     angle += 90;
                                     }
                            j-=1
                        }
                 }
               }
         if(flame>1200)
              {
		if(count==520)		
                {
                        let j=3;
                        while(j>1)
                        {
                            let angle = 90;
                            loop(90) {
                                     CreateShot01(GetX, GetY, j, angle, ORANGE05, 0);
                                     angle += 4;
                                     }
                            j-=1
                        }
                 }                               
               }

         

         if(flame>2400)
               {
		           if(count==0)		
                                        {
                                          let j=5;
                                          while(j>1)
                                              {
                                               let radius = 100;
                                               let angle = 90;
                                               loop(90) {
                                                         let g = GetX + offsetX(radius, angle);
                                                         let t = GetY + offsetY(radius, angle);
                                                         CreateLaser01(g, t, j, angle, 70,4,YELLOW05, 30);
                                                         angle += 8;
                                                         }
                                               j-=1
                                               }
                                         }
                 }

        if(flame==7200){PlaySE(bom36);
			PlaySE(shot1);}
        if(flame>7200)
               {
                 let f=rand(0,360);
                 CreateShot02(GetX-12+f/15,GetY-12+f/15,1+f/40,f,-0.1,1.5,PURPLE01, 5);
                }


        if(GetEnemyLife<210&&count==100){PlaySE(bom36);
					PlaySE(shot1);}
        if(GetEnemyLife<180)
               {
                 let f=rand(0,360);
                 CreateShot02(GetX-12+f/15,GetY-12+f/15,1+f/40,f,-0.1,1.5,PURPLE01, 5);
                }
 
       if(GetEnemyLife<40)
               {
                Slow(2);
                MotionBlurEx(ALL,50,100,ALPHA);
                let f=rand(0,360);
                CreateShot02(GetX-12+f/15,GetY-12+f/15,1+f/20,f,-0.1,3,WHITE02, 5);
               }
       if(GetEnemyLife<50&&flame%20==1){PlaySE(bom36);}

                function offsetX(radius, angle) {
                return radius * cos(angle);
                }

                function offsetY(radius, angle) {
                return radius * sin(angle);
                }


                if(flame==0)
                      {                     
                       Concentration01(100);
                       Concentration02(200);
                      }
 		if(flame==150){PlaySE(eco00);}
                if(flame==800){PlaySE(bom36);
				PlaySE(shot1);}
                if(flame==1400){PlaySE(bom36);
				PlaySE(shot1);}
                if(flame==2000){PlaySE(bom36);
				PlaySE(shot1);}
                if(flame==2600){PlaySE(bom36);
				PlaySE(shot1);}
                if(flame==8700){Slow(2);}
                if(flame==8700){
                                PlaySE(bom36);
				PlaySE(shot1);
                                MotionBlurEx(ALL,320,100,ALPHA);
                                let f=rand(0,360);
                                CreateShot02(GetX-12+f/15,GetY-12+f/15,1+f/20,f,-0.1,3,WHITE02, 5);
                                }
                if(flame==8910){PlaySE(bom36);
				PlaySE(shot1);}
                if(flame==8940){PlaySE(bom36);
				PlaySE(shot1);}
                if(flame==8970){PlaySE(bom36);
				PlaySE(shot1);}
                if(flame==8999){PlaySE(bom36);
				PlaySE(shot1);}

           if(flame>300)
               {
		SetCollisionA(GetX(),GetY(),32);//蔻(e)o^
		SetCollisionB(GetX(),GetY(),24);//蔻(̓)o^
               }
		count++;
                flame++;
	}
	
	@Finalize
	{//ǂ݂񂾃t@C폜
          PlaySE(bom36);
          PlaySE(shot1);
	  Explosion01(GetX,GetY,3,5,120);
          DeleteGraphic(imgExRumia);  
                
          loop(100)
              {
	       CreateItem(ITEM_SCORE,GetX+rand(-100,100),GetY+rand(20,100));
               }
         CollectItems();
         
               
	}
	
	@DrawLoop
	{
		//Ex[~A`
	 if(flame>300)
               {	
                SetGraphicRect(64,1,127,64);                             
		SetAlpha(255);
		SetTexture(imgExRumia);
		DrawGraphic(GetX(),GetY());
	       }
		if(flame>300)
			{

			SetGraphicRect(0,80,150,230);
			SetAlpha(255);
			SetGraphicAngle(0,0,-imgAngle);
			SetTexture(imgeffect_magic);
			DrawGraphic(GetX(),GetY());
			imgAngle+=0.5;
			}

		if(flame>300)
			{

			SetGraphicRect(300,230,450,380);
			SetAlpha(255);
			SetGraphicAngle(0,0,imgAngle);
			SetTexture(imgeffect_magic);
			DrawGraphic(GetX(),GetY());
			imgAngle+=0.5;
			}

                              
	}

	@BackGround
	{
	//XyJ[h̔wi
	//Ă悢


		SetTexture(imgLuna);
		SetGraphicRect(1,1,384,448);
		SetAlpha(255);
		SetGraphicAngle(0,0,0);
		DrawGraphic(GetCenterX,GetCenterY);
				
	}


    function offsetX(radius, angle) {
        return radius * cos(angle);
    }

    function offsetY(radius, angle) {
        return radius * sin(angle);
    }

}


